package Persistance.KMeans;

public class Point
{
    private static final int MAX = 18;

    private double x[];
    private String	_name;
	private Cluster	_cluster;
	private double	_distance;

	public Point(double x[], String _name)
	{
		super();
        this.x = new double[MAX];
        System.arraycopy(x, 0, this.x, 0, MAX);
        this._name = _name;
		this._cluster = null;
	}


	public void setCluster(Cluster cluster)
	{
		this._cluster = cluster;
		calcDistance();
	}

	public void calcDistance()
	{
		_distance = 0;

        for(int i=0;i<MAX;i++){
            _distance += Math.pow((x[i] - _cluster.getCenter().get(i)), 2);
        }

        _distance = Math.sqrt(_distance);

	}

	public double checkDistance(ClusterCenter c)
	{
        double temp = 0;

        for(int i=0;i<MAX; i++){
            temp += Math.pow((x[i] - c.get(i)), 2);
        }

        return Math.sqrt(temp);
	}

    public double get(int i){
        return this.x[i];
    }

	public Cluster getCluster()
	{
		return _cluster;
	}

	public double getCurrentDistance()
	{
		return _distance;
	}

	public String getName()
	{
		return _name;
	}
}